package com.billdowney.controller.main;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.billdowney.annotation.AuthRoleAllowed;
import com.billdowney.controller.BaseController;
import com.billdowney.service.interfaces.system.SystemDataDictService;
import com.billdowney.service.util.system.SystemDataDictConst;
import com.billdowney.util.CommonUtil;
import com.billdowney.util.auth.AuthRoleConst;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Controller
@RequestMapping(method = { RequestMethod.POST, RequestMethod.GET })
@Api(tags = "欢迎页处理控制器")
public class IndexController extends BaseController {

	@Autowired
	private SystemDataDictService systemDataDictService;

	@AuthRoleAllowed(AuthRoleConst.NOT_LOGIN)
	@RequestMapping(value = "/")
	@ApiOperation(value = "进入首页")
	public String welcomePage() throws Exception {
		String indexPath = systemDataDictService.getString(SystemDataDictConst.indexPagePath);
		if (CommonUtil.isEmpty(indexPath)) {
			return "index";
		}
		return indexPath;
	}

	@AuthRoleAllowed(AuthRoleConst.NOT_LOGIN)
	@RequestMapping(value = "/manage")
	@ApiOperation(value = "进入管理页")
	public String manage() throws Exception {
		return systemDataDictService.getString(SystemDataDictConst.managePagePath);
	}

}
